const portfinder = require('portfinder');

portfinder.basePort = 1212;
portfinder
  .getPortPromise()
  .then((port) => {
    //
    // `port` is guaranteed to be a free port
    console.log(port, 'port-20240728');
    // in this scope.
    //
  })
  .catch((err) => {
    //
    // Could not get a free port, `err` contains the reason.
    console.log('找不到可用端口-no port to start');
    //
  });
